<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>axios文件上传</title>
</head>
<body>
<div>
    <input type="file" id="ipt-file">
    <img src="" id="img-content">
</div>

</body>
</html>
<script src="./axios.min.js"></script>
<script>
    document.getElementById("ipt-file")
        .onchange = function (e) {
            console.log(e)
            //表单数据对象
            const fd = new FormData()
            //事件的 触发的元素对象
            //文件类型
            fd.append("img", e.target.files[0])

            axios.post('/files/upload02',fd)
                .then( res => {

                    console.log(res.data)

                    document.getElementById("img-content")
                        .src = res.data

                });






        }



</script>